﻿using System;
using Besture.Common.Helper;
using Besture.UI.ClassHelper;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.Data;
using Besture.Common;
using Besture.Bll;

namespace Besture.UI
{
    public partial class AppraisalList : BasePage
    {
        #region 页面加载

        /// <summary>
        /// 初始化页面
        /// </summary>
        protected override void InitialLoad()
        {
            //初始化页面
            InitPage();
            BindData();
            AspxGridViewHelper.InitAspxGridView(grid);
        }

        /// <summary>
        /// 回发
        /// </summary>
        protected override void PostBackLoad()
        {
            BindData();
        }

        /// <summary>
        /// 初始化页面
        /// </summary>
        public void InitPage()
        {

        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        public void BindData()
        {
            var dac = new AppraisalDac();
            grid.DataSource = dac.GetDataTable();
            grid.DataBind();
        }

        /// <summary>
        /// AspxGridView回发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridCustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (e.Parameters == "Refresh")
                grid.DataBind();
        }
        #endregion 

        #region

        /// <summary>
        /// 审核  选中数据
        /// </summary>
        public void UpdateSelect(int iCheckStatus)
        {
            string ids = AspxGridViewHelper.GetCheckID(grid);
            if (string.IsNullOrEmpty(ids))
            {
                return;
            }
            AppraisalDac partDac = new AppraisalDac();
            partDac.Update(ids, iCheckStatus);
            BindData();
        }

        protected void lbClose_Click(object obj, EventArgs eventArgs)
        {
            //0 审核中 1 已审核 2 取消审核
            UpdateSelect(2);
        }
        protected void lbAdd_Click(object obj, EventArgs eventArgs)
        {
            //0 审核中 1 已审核 2 取消审核
            UpdateSelect(1);
        }
        #endregion
    }
}